import { PID } from '../actor/pid';

/**
 * 远程消息接口
 */
export interface RemoteMessage {
  type: string;
  message: any;
}

/**
 * 远程终止消息
 */
export class RemoteTerminate implements RemoteMessage {
  public readonly type: string = 'REMOTE_TERMINATE';
  public readonly message: any;

  constructor(
    public readonly targetPID: PID,
    public readonly watcher: any
  ) {
    this.message = { targetPID, watcher };
  }
}

/**
 * 远程监视消息
 */
export class RemoteWatch implements RemoteMessage {
  public readonly type: string = 'REMOTE_WATCH';
  public readonly message: any;

  constructor(
    public readonly targetPID: PID,
    public readonly watcherPID: PID,
    public readonly watcher: any
  ) {
    this.message = { targetPID, watcherPID, watcher };
  }
}

/**
 * 远程取消监视消息
 */
export class RemoteUnwatch implements RemoteMessage {
  public readonly type: string = 'REMOTE_UNWATCH';
  public readonly message: any;

  constructor(
    public readonly targetPID: PID,
    public readonly watcher: any
  ) {
    this.message = { targetPID, watcher };
  }
}

/**
 * 远程投递消息
 */
export class RemoteDeliver implements RemoteMessage {
  public readonly type: string = 'REMOTE_DELIVER';
  public readonly message: any;

  constructor(
    public readonly targetPID: PID,
    public readonly payload: any
  ) {
    this.message = { targetPID, payload };
  }
}

/**
 * 远程 Future 消息
 */
export class RemoteFuture implements RemoteMessage {
  public readonly type: string = 'REMOTE_FUTURE';
  public readonly message: any;

  constructor(
    public readonly targetPID: PID,
    public readonly payload: any
  ) {
    this.message = { targetPID, payload };
  }
} 